<?php
/**
 * 用户日志逻辑类
 * @author zengnz
 *
 */
class LogLogic
{
	// 用户操作日志缓存
	const USER_ACTION_LOG = 'USER_ACTION_LOG_';
	// 用户登录日志缓存
	const USER_LOGIN_LOG = 'USER_LOGIN_LOG_';
	
	// 分表数目
	private $_tables = 5;
	
	// 数据模型类
	private $_Model = '';
	
	public function __construct() {
		$this -> _Model = new Model();
	}
	
	/**
	 * 添加操作日志
	 * @param integer $uId
	 * @param string $account
	 * @param integer $type 1.add,2.update,3.del
	 * @param string $intro
	 */
	public function addActionLog( $uId, $account, $type, $intro ) {
		if (!$uId || !$account || !$type || !$intro)
			return -1;
		
		// 分表后缀
		$tbSuffix = $uId % $this -> _tables;
		
		$data = array(
			'customer_id' => $uId,
			'name'		  => $account,
			'type'	 	  => $type,
			'summary'	  => $intro,
			'action_time' => time()						
		);
		
		$ret = $this -> _Model -> table('log_customer_action_'.$tbSuffix) -> add($data);
		
		return $ret;
	}
	
	
}